package top.ochiamalu.aioj.util;

import top.ochiamalu.aioj.common.BaseResponse;
import top.ochiamalu.aioj.common.ErrorCode;

/**
 * 结果工具类
 *
 * @author ochiamalu
 * @date 2025/01/23
 */
public final class ResultUtils {
    private ResultUtils() {
        throw new IllegalStateException("Utility class");
    }

    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(0, data, "ok");
    }

    public static <T> BaseResponse<T> error(ErrorCode errorCode) {
        return new BaseResponse<>(errorCode);
    }

    public static <T> BaseResponse<T> error(int code, String message) {
        return new BaseResponse<T>(code, null, message);
    }

    public static <T> BaseResponse<T> error(ErrorCode errorCode, String message) {
        return new BaseResponse<T>(errorCode.getCode(), null, message);
    }
}
